package sma.sync.mgr;

import java.io.File;
import java.util.Map.Entry;
import java.util.Set;

import org.apache.log4j.Logger;

import sma.sync.model.DestFolder;
import sma.sync.model.SourceFolder;

public class Synchroniser {

	/** Log4J */
	private static final Logger sLog = Logger.getLogger(Synchroniser.class);

	public void runSynchro(File pSource, File pDest) {
		SourceFolder fSource = new SourceFolder(pSource);
		fSource.analyse();
		DestFolder foldDest = new DestFolder(pDest);
		foldDest.setSourceFolder(fSource);
		foldDest.analyse();

		Set<Entry<File, File>> sourceToDestDirEntries = foldDest.getSourceToDestDir().entrySet();
		for (Entry<File, File> entry : sourceToDestDirEntries) {
			this.synchronizeDirectory(entry.getKey(), entry.getValue());
		}
	}

	private void synchronizeDirectory(File pSourceDir, File pDestDir) {
		sLog.info("From " + pSourceDir + " to " + pDestDir);
	}

}
